home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / PSHDIR1A.ZIP / PUSHDIR.LST < prev    next >
File List  |  1988-12-22  |  22KB  |  317 lines

  1. Turbo Assembler  Version 1.0        12-22-88 23:23:19         Page 1
  2. PUSHDIR.ASM
  3.  
  4.       1                              main    group   code
  5.       2 0000                         code    segment public  para    'code'
  6.       3                              assume  cs:main
  7.       4
  8.       5                              org     100h                            ;.COM file
  9.       6
  10.       7 0100  E9 020F                BEGIN:  jmp     START                   ;program starts here
  11.       8                              ;               db      "Copyright 1986 Ziff-Davis Publishing Co.",1Ah
  12.       9                              ;                       Changes made on 12/22/88 by Mike Williams
  13.      10                              ;                       1. Support command line parm to also CHDIR
  14.      11                              ;                       2. If path string refers to a drive, log that drive
  15.      12                              ;
  16.      13 0103  50 55 53 48 44 49 52 + signature       db      'PUSHDIR VERSION 1.a'
  17.      14       20 56 45 52 53 49 4F +
  18.      15       4E 20 31 2E 61
  19.      16       = 0013                 lengthsignature = $ - signature
  20.      17
  21.      18 0116  ????????               savedint16      dd      ?               ;old int 16h vector
  22.      19
  23.      20 011A  011Cr                  nextpush        dw      offset main:push1dir    ;next place to save a dir
  24.      21 011C  43*(00)                push1dir        db      67 dup (0)              ;storage for a saved dir
  25.      22 015F  43*(00)                push2dir        db      67 dup (0)              ;more storage
  26.      23 01A2  43*(00)                push3dir        db      67 dup (0)              ;more storage
  27.      24 01E5  43*(00)                push4dir        db      67 dup (0)              ;more storage
  28.      25 0228  43*(00)                push5dir        db      67 dup (0)              ;more storage
  29.      26 026B  43*(00)                push6dir        db      67 dup (0)              ;last storage
  30.      27
  31.      28                              ;up to here must be EXACTLY identical in both PUSHDIR and POPDIR so that
  32.      29                              ;popdir can know how to access the memory space reserved by the first
  33.      30                              ;pushdir.
  34.      31
  35.      32                              ;myint16 is an interrupt handler chained onto the existing interrupt handler.
  36.      33                              ;it is used to find out if PUSHDIR is already installed and if it is, where
  37.      34                              ;is it located?  It works by adding another function to int 16h.  To use it
  38.      35                              ;ax = 7788h, bx = 7789h, and ds:si points to the signature string.  If any one
  39.      36                              ;of these conditions is not true, then the int 16h call is passed onto the
  40.      37                              ;old routine without doing anything.  If they are all true, then we switch
  41.      38                              ;ax and bx and return ds = code segment (cs) of the interrupt handler.
  42.      39
  43.      40 02AE                         myint16 proc    far
  44.      41
  45.      42 02AE  9C                             pushf                           ;save flags
  46.      43 02AF  3D 7788                        cmp     ax,7788h                        ;possible signature request ?
  47.      44 02B2  74 06                          je      CHECKSIG                        ;yes
  48.      45                              NOTSIG:
  49.      46 02B4  9D                             popf                            ;no - recover flags
  50.      47 02B5  2E: FF 2E 0116r                jmp     cs:[savedint16]         ;go to old routine as normal
  51.      48
  52.      49                              CHECKSIG:
  53.      50 02BA  81 FB 7789                     cmp     bx,7789h                ;possible signature request ?
  54.      51 02BE  75 F4                          jne     NOTSIG                  ;no
  55.      52
  56.      53                                      ;ax and bx were correct for a signature request
  57.      54                                      ;now see if ds:si was pointing to the signature string
  58.      55                                      ;the whole idea of the signature is that is has to be
  59.      56                                      ;totally unique so no other program could possibly use the same one.
  60.      57
  61.      58 02C0  06                             push    es                      ;save the registers we will use
  62.      59 02C1  57                             push    di
  63. Turbo Assembler  Version 1.0        12-22-88 23:23:19         Page 2
  64. PUSHDIR.ASM
  65.  
  66.      60 02C2  51                             push    cx
  67.      61 02C3  BF 0103r                       mov     di,offset main:signature        ;address of the signature
  68.      62 02C6  B9 0013                        mov     cx,lengthsignature              ;length of the signature
  69.      63 02C9  F3> A6                         repe    cmpsb                   ;does string at ds:si match es:di ?
  70.      64 02CB  59                             pop     cx                      ;recover all registers we used
  71.      65 02CC  5F                             pop     di
  72.      66 02CD  07                             pop     es
  73.      67 02CE  75 E4                          jne     NOTSIG                  ;no, not correct signature
  74.      68
  75.      69                              ;yes, it was a signature request so return ds equal to the current code
  76.      70                              ;segment so subsequent pushdir's and popdir's know where the original
  77.      71                              ;is located.
  78.      72
  79.      73 02D0  0E                             push    cs
  80.      74 02D1  1F                             pop     ds                      ;set ds = cs
  81.      75 02D2  93                             xchg    ax,bx                   ;flip these two so we know that
  82.      76                                                                      ;ds is being returned
  83.      77 02D3  9D                             popf                            ;recover original flags
  84.      78 02D4  CF                             iret                            ;return back to the program
  85.      79                                                                      ;that called the int 16h
  86.      80
  87.      81 02D5                         myint16 endp
  88.      82
  89.      83                              endresident     label   byte            ;label marking the end of the
  90.      84                                                                      ;code to remain resident
  91.      85
  92.      86                              ;code after here will not remain resident
  93.      87
  94.      88 02D5  01                     install         db      1       ;0 = already installed, 1 = not installed
  95.      89
  96.      90 02D6  45 72 72 6F 72 20 72 + abortmsg        db      'Error reading the current directory.$'
  97.      91       65 61 64 69 6E 67 20 +
  98.      92       74 68 65 20 63 75 72 +
  99.      93       72 65 6E 74 20 64 69 +
  100.      94       72 65 63 74 6F 72 79 +
  101.      95       2E 24
  102.      96 02FB  50 55 53 48 44 49 52 + installmsg      db      'PUSHDIR 1.a installed.$'
  103.      97       20 31 2E 61 20 69 6E +
  104.      98       73 74 61 6C 6C 65 64 +
  105.      99       2E 24
  106.     100
  107.     101 0312                         START:
  108.     102 0312  FB                             sti                             ;turn interrupts on
  109.     103
  110.     104                                      ;first check to see if PUSHDIR is already installed
  111.     105
  112.     106 0313  B8 7788                        mov     ax,7788h                        ;signature request
  113.     107 0316  BB 7789                        mov     bx,7789h                        ;signature request
  114.     108 0319  BE 0103r                       mov     si,offset main:signature        ;point to signature
  115.     109 031C  CD 16                          int     16h                     ;is it installed ?
  116.     110
  117.     111                              assume  ds:nothing
  118.     112
  119.     113 031E  81 FB 7788                     cmp     bx,7788h                        ;were ax and bx switched ?
  120.     114 0322  75 0B